export default class extends think.BaseController {

    /**
         * 获取部门及用户（根据用户岗位）
         */
    async getDepartAndUserAction() {
        let aj = think.ajaxJson();
        const JobService = this.service('overallmerit/JobService');
        const data = {
            post_code: this.get('post_code')
        };
        const res = await JobService.getDepartAndUser(data);
        if (res && res.error) {
            aj.success = false;
            aj.msg = '查询失败';
        } else {
            aj.result = res;
        }
        return this.json(aj);

    }
    /**
         * 按岗位编码获取用户列表
         */
    async getAllUserByPostCodeAction() {
        let aj = think.ajaxJson();
        const JobService = this.service('overallmerit/JobService');
        const data = {
            post_code: this.get('post_code')
        };
        const res = await JobService.getAllUserByPostCode(data);
        if (res && res.error) {
            aj.success = false;
            aj.msg = '查询失败';
        } else {
            aj.result = res;
        }
        return this.json(aj);
    }
    /**
         * 信息采集员岗位评价（人员|时间）
         */
    async getCollectEvalListAction() {
        let aj = think.ajaxJson();
        const JobService = this.service('overallmerit/JobService');
        const data = this.post('cycle,rangeDate,rangeDate2,userList');
        const res = await JobService.getCollectEvalList(data);
        if (res && res.error) {
            aj.success = false;
            aj.msg = '查询失败';
        } else {
            aj.result = res;
        }
        return this.json(aj);
    }
    /**
         * 受理人员岗位评价
         *
         */
    async getCenterPerEvalListAction() {
        let aj = think.ajaxJson();
        const JobService = this.service('overallmerit/JobService');
        const data = this.post('cycle,rangeDate,rangeDate2,userList');
        const res = await JobService.getCenterPerEvalList(data);
        if (res && res.error) {
            aj.success = false;
            aj.msg = '查询失败';
        } else {
            aj.result = res;
        }
        return this.json(aj);
    }
    /**
         * 其他岗位 岗位评价
         *
         */
    async getOhterPostEvalListAction() {
        let aj = think.ajaxJson();
        const JobService = this.service('overallmerit/JobService');
        const data = this.post('cycle,rangeDate,rangeDate2,userList');
        const res = await JobService.getOhterPostEvalList(data);
        if (res && res.error) {
            aj.success = false;
            aj.msg = '查询失败';
        } else {
            aj.result = res;
        }
        return this.json(aj);
    }

    async getAllPostAction() {
        let aj = think.ajaxJson();
        const JobService = this.service('overallmerit/JobService');
        const res = await JobService.getAllPost();
        if (res && res.error) {
            aj.success = false;
            aj.msg = '查询失败';
        } else {
            aj.result = res;
        }
        return this.json(aj);
    }

    async getAllUserAction() {

        const JobService = this.service('overallmerit/JobService');
        const res = await JobService.getAllUser();
        if (res) {
            return this.successJson(res)
        } else {
            return this.errorJson('查询失败')
        }

        return this.json(aj);
    }

}
